home *** CD-ROM | disk | FTP | other *** search
/ Minami 56 / MINAMI56.ISO / Extra / winamp505_full.exe / $R0 / Winamp Modern / mute.m < prev    next >
Text File  |  2004-07-01  |  2KB  |  102 lines

  1. #include <lib/std.mi>
  2.  
  3. Function updateVolume(int v);
  4.  
  5. Global Group frameGroup;
  6. Global Togglebutton MuteBtn,MuteBtnShade;
  7. Global Timer SongTickerTimer;
  8. Global Text SongTicker;
  9. Global Float VolumeLevel;
  10. Global Boolean Muted,BtnPressed;
  11. Global Layer volumebar;
  12. Global Timer callback;
  13.  
  14. System.onScriptLoaded() {
  15.  
  16.     frameGroup = getScriptGroup();
  17.     MuteBtn = frameGroup.findObject("mute");
  18.     callback = new Timer; callback.setDelay(5); callback.start();
  19.     SongTicker = frameGroup.findObject("songticker");
  20.  
  21.     volumebar = frameGroup.findObject("volumebar");
  22.     volumebar.setXmlParam("w",integertostring( (system.getVolume()/255) *70 + 5));
  23.  
  24.     SongTickerTimer = new Timer;
  25.     SongTickerTimer.setDelay(1000);
  26.  
  27.     Muted = 0;
  28.     BtnPressed = 0;
  29. }
  30.  
  31. System.OnScriptUnloading() {
  32.     delete callback;
  33. }
  34.  
  35. callback.onTimer() {
  36.     MuteBtnShade = getcontainer("main").getlayout("shade").findObject("shademute");
  37.     if (MuteBtnShade != NULL) stop();
  38. }
  39.  
  40. SongTickerTimer.onTimer() {
  41.     SongTicker.setText("");
  42.     SongTickerTimer.stop();
  43. }
  44.  
  45. MuteBtn.onLeftClick() {
  46.     BtnPressed = 1;
  47.     if (!Muted) {
  48.         VolumeLevel = System.getVolume();
  49.         System.setVolume(0);
  50.         Muted = 1;
  51.         SongTickerTimer.start();
  52.         SongTicker.setText("Mute ON");
  53.         MuteBtnShade.setActivated(1);
  54.     } else {
  55.         System.setVolume(VolumeLevel);
  56.         Muted = 0;
  57.         SongTickerTimer.start();
  58.         SongTicker.setText("Mute OFF");
  59.         MuteBtnShade.setActivated(0);
  60.     }
  61. }
  62.  
  63. MuteBtnShade.onLeftClick() {
  64.     BtnPressed = 1;
  65.     if (!Muted) {
  66.         VolumeLevel = System.getVolume();
  67.         System.setVolume(0);
  68.         Muted = 1;
  69.         SongTickerTimer.start();
  70.         SongTicker.setText("Mute ON");
  71.         MuteBtn.setActivated(1);
  72.     } else {
  73.         System.setVolume(VolumeLevel);
  74.         Muted = 0;
  75.         SongTickerTimer.start();
  76.         SongTicker.setText("Mute OFF");
  77.         MuteBtn.setActivated(0);
  78.     }
  79. }
  80.  
  81. System.onScriptUnloading() {
  82.     delete SongTickerTimer;
  83. }
  84.  
  85. System.onvolumechanged(int newvol)
  86. {
  87.     volumebar.setXmlParam("w",integertostring( (newvol/255) *70 + 5));
  88.     if (!BtnPressed) {
  89.         SongTickerTimer.start();
  90.         SongTicker.setText("Volume:" + System.integerToString(newvol/2.55) + "%");
  91.  
  92.         if (Muted) {
  93.             MuteBtn.setActivated(0);
  94.             MuteBtnShade.setActivated(0);
  95.             Muted = 0;
  96.         }
  97.     }
  98.     BtnPressed = 0;
  99. }
  100.  
  101.  
  102.